package br.com.mizzu.taglibs;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import br.com.mizzu.controllers.IndexController;

public class teste extends TagSupport {

	private static final long serialVersionUID = 1L;
	private String palavra="";
	private String var;
	private List lista;

	public teste() {
         super();
     }

	/*@Override
     public int doStartTag() throws JspException {
        try {
            pageContext.getOut().print("teste bem sucedido");
            pageContext.getOut().print(palavra);
        } catch (IOException e) {
            throw new JspException(e.getMessage());
        }
        System.out.println(palavra);
        return SKIP_BODY;
     }*/
	
	
	   private int counter = 0 ;
	   private String [] names = null ;

	   public int doStartTag ()
	   {
	     /*//names = (String []) pageContext.getAttribute (palavra) ;
	     String s =  (String) pageContext.getAttribute ("index");
	     Object att = (IndexController) pageContext.getRequest().getAttribute("index");

			try {
		    	Class<? extends Object> clazz = att.getClass();
				Method metodo = clazz.getMethod("getFrase");
				Object value;
				value = metodo.invoke(att);
				System.out.println("terceiro teste: "+value);
				System.out.println(lista.size());
				
			} catch (IllegalAccessException | IllegalArgumentException
					| InvocationTargetException | NoSuchMethodException | SecurityException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}*/
		   try {
			pageContext.getOut().print(palavra);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	     return EVAL_BODY_INCLUDE;
	   }

	   /*public int doAfterBody () throws JspException
	   {
	     try {
	       pageContext.getOut () .print ( " " + names [ counter ] + "<BR>" ) ;
	     } catch ( Exception e ){
	       throw new JspException ( e.toString ()) ;
	     }
	     counter++;
	     if ( counter >= names.length ) {
	       return SKIP_BODY;
	     }
	     return EVAL_BODY_AGAIN;
	   }*/

	public String getPalavra() {
		return palavra;
	}

	public void setPalavra(String palavra) {
		this.palavra = palavra;
	}

	public List getLista() {
		return lista;
	}

	public void setLista(List lista) {
		this.lista = lista;
	}

	public String getVar() {
		return var;
	}

	public void setVar(String var) {
		this.var = var;
	}

	/*
	@Override
    public int doEndTag() throws JspException {
    	System.out.println(palavra);
    	return super.doEndTag();
    }
     
     public void setPalavra(String palavra) {
		this.palavra = palavra;
	}*/
}
